<html>
<head>
<title>websockets client demo</title>
</head>
<script>
function onBodyLoad() {
  port = 12500;
  websocket = new WebSocket('ws://localhost:'+port+'/tmweb/websockets/websockets_server.php');
  websocket.onopen = function(evt) { onOpen(evt) };
  websocket.onclose = function(evt) { onClose(evt) };
  websocket.onmessage = function(evt) { onMessage(evt) };
  websocket.onerror = function(evt) { onError(evt) };
}

function debug(AMessage) {
  var d = document.getElementById('debug')
  d.innerHTML += AMessage+"\n";
}

function onOpen(AEvent) {
  debug('onOpen: CONNECTED to server at port '+port);
  //debug('onOpen: '+AEvent);
  //debug('  data='+AEvent.data);
}

function onClose(AEvent) {
  debug('onClose: Connection CLOSED to server at port '+port);
  //debug('onClose: '+AEvent);
  //debug('  data='+AEvent.data);
}

function onMessage(AEvent) {
  debug('onMessage: '+AEvent.data);
  //debug('onMessage: '+AEvent);
  //debug('  data='+AEvent.data);
}

function onError(AEvent) {
  debug('onError: '+AEvent);
  debug('  data='+AEvent.data);
}

</script>
<body onload="onBodyLoad()">

  <button onclick="websocket.send('test'+Math.floor(Math.random()*1000))">test send</button>
  <button onclick="websocket.send('hello')">websocket.send('hello')</button>

  <pre id="debug">
  </pre>

</body>
</html>